import Control.Monad

ac :: String -> Int
ac [] = 0
ac xs = fst $ foldl (\a x -> if snd a == x then ((fst a) + 1, x) else ((fst a), x)) (0, ' ') xs

main = do
    q <- readLn
    xs <- replicateM q getLine
    mapM_ (putStrLn . show . ac) xs    